# 判断是否是闰年
def isleap(year):
    return (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0)


# 获取月份天数
def getmaxdays(year, month):
    d = 30
    if month in [1, 3, 5, 7, 8, 10, 12]:
        d = 31
    elif month == 2:
        d = 29 if isleap(year) else 28
    return d


# 获取这一天是当年的第几天
def countdays(y, m, d):
    days = d
    for i in range(1, m):
        days += getmaxdays(y, i)
    return days

# 每月第一天是星期几
def countweek(y, m):
    w = (y - 1) + (y - 1) // 400 + (y - 1) // 4 - (y - 1) // 100 + countdays(y, m, 1)
    return w % 7

#打印某月的日历
def printmonth(y, m):
    w = countweek(y, m)
    md = getmaxdays(y, m)
    print(f"{'sun':<6}{'Mon':<6}{'Tue':<6}{'Wed':<6}{'Thu':<6}{'Fri':<6}{'Sat':<6}")
    for i in range(w):
        print(f"{' ':<6}", end="")
    for d in range(1, md + 1):
        print(f"{d:<6}", end="")
        w = w + 1
        if w % 7 == 0:
            print()
    print()
if __name__ == '__main__':
    year = int(input("请输入年份"))
    for m in range(1, 13):
        print(f"{'-' * 15}{year}年{m}月{'-' * 15}")
        printmonth(year, m)

